<template>
    <div class="body">
        <van-address-list
        v-model="chosenAddressId"
        :list="list"
        default-tag-text="默认"
        tel="phone"
        @add="onSet"
        @edit="onSet"
        />
    </div>
</template>
<script>
import {Toast} from 'vant'
import {AddressList} from '../ajax'
export default {
    data() {
        return {
            chosenAddressId: '1',
            list: [
            {
                id: '1',
                name: '张三',
                tel: '13000000000',
                address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
            },
            {
                id: '2',
                name: '李四',
                tel: '1310000000',
                address: '浙江省杭州市拱墅区莫干山路 50 号',
            }
        ],
        }
    },
    created(){
        this.getAddressList();
    },
    methods:{
        getAddressList(){
            const data = {
                uid:this.$store.getters.wxUserInfo.userinfo.id
            }
            AddressList(data).then(res=>{
                console.log(res);
                for(let i of res){
                    i.address = i.province+i.city+i.area+i.dedail;
                    i.address1 = i.province+i.city+i.area;
                }
                this.list = res;
            })
        },
        onSet(item) {
            // console.log(item);
            this.$store.commit('set_address',item);
            this.$router.push('/addressEdit')
        },
    }
}
</script>
<style lang="scss" scoped>
    $green:#3DCEB9;
    .body{
        height: calc(100vh - 6rem);
        background: #F2F2F2;
        overflow: auto;
        .van-address-item .van-radio__icon--checked .van-icon{
            background-color: $green;
            border-color:$green
        }
    }
    .van-button--danger{
        background-color:$green;
        border-color: $green;
    }
</style>